package com.itheima79.googleplay.holder;

import android.text.format.Formatter;
import android.view.View;
import android.view.animation.OvershootInterpolator;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.itheima79.googleplay.R;
import com.itheima79.googleplay.bean.AppInfo;
import com.itheima79.googleplay.global.GooglePlayApplication;
import com.itheima79.googleplay.global.ImageLoaderOptions;
import com.itheima79.googleplay.http.Api;
import com.nineoldandroids.view.ViewHelper;
import com.nineoldandroids.view.ViewPropertyAnimator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

public class HomeHolder extends BaseHolder<AppInfo>{
	ImageView iv_icon;
	RatingBar rb_star;
	TextView tv_name,tv_size,tv_des;

	/**
	 * 初始化holderView
	 * @return
	 */
	public View initHolderView() {
		View view = View.inflate(GooglePlayApplication.context, R.layout.adapter_home, null);
		iv_icon = (ImageView) view.findViewById(R.id.iv_icon);
		rb_star = (RatingBar) view.findViewById(R.id.rb_star);
		tv_name = (TextView) view.findViewById(R.id.tv_name);
		tv_size = (TextView) view.findViewById(R.id.tv_size);
		tv_des = (TextView) view.findViewById(R.id.tv_des);
		
		return view;
	}
	
	/**
	 * 绑定数据的操作
	 * @param appInfo
	 */
	public void bindData(AppInfo appInfo){
		tv_name.setText(appInfo.getName());
		rb_star.setRating(appInfo.getStars());
		tv_size.setText(Formatter.formatFileSize(GooglePlayApplication.context,appInfo.getSize()));
		tv_des.setText(appInfo.getDes());
		
		//使用ImageLoader加载图片
		ImageLoader.getInstance().displayImage(Api.IMAGE_PREFIX+appInfo.getIconUrl(), iv_icon,ImageLoaderOptions.round_options);
		
	}
	
}
